package com.xintonghua.bussiness.ui;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;

import com.xintonghua.base.widget.ConfirmDialog;
import com.xintonghua.bussiness.BuildConfig;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.api.manager.AuthManager;
import com.xintonghua.bussiness.base.BaseActivity;
import com.xintonghua.bussiness.util.MyState;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 作者：wanxianyi
 * 时间：2018/7/18.
 * 包名：com.xintonghua.bussiness.ui
 */
public class ExchargeActivity extends BaseActivity {
    @BindView(R.id.et_excharge)
    EditText etExcharge;
    @BindView(R.id.btn_excharge)
    Button btnExcharge;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_excharge);
        ButterKnife.bind(this);
        onSimpleActionBar();
        setSimpleActionBar("充值");
    }

    @OnClick(R.id.btn_excharge)
    public void onViewClicked() {
        if (TextUtils.isEmpty(etExcharge.getText().toString())) {
            mToast("请输入金额");

        } else {
            if (Integer.valueOf(etExcharge.getText().toString()) <= 0) {
                mToast("提现金额不能小于0");
            } else {
                ConfirmDialog.showDialog(this, "温馨提示", "是否确认充值？", "取消", "确定", null, new ConfirmDialog.OnRightListener() {
                    @Override
                    public void onClick(ConfirmDialog dialog) {
                        httpCent.saveBalance(getIntent().getStringExtra(BuildConfig.FLAVOR), AuthManager.geteAuth().getShop_id() + "", etExcharge.getText().toString(), ExchargeActivity.this, MyState.requestOne);

                    }
                });
            }
        }
    }

    @Override
    public void dataBack(Object data, int order) {
        super.dataBack(data, order);
        switch (order){
            case MyState.requestOne:
                mToast("充值成功！");
                finish();
                break;
        }
    }
}
